{extend name="admin@public/basic" /}

{block name="style"}
<link rel="stylesheet" href="__STATIC__/css/admin/public.css" media="all"/>
{/block}

{block name="cotent"}
<form class="layui-form">
    <blockquote class="layui-elem-quote quoteBox">
        <form class="layui-form">
            <input type="hidden" id="app_sn" value="{$app_sn}"/>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" class="layui-input equipments_sn" placeholder="请输入产品编号"/>
                </div>
<!--                <div class="layui-input-inline">-->
<!--                    <select name="sim_status" class="sim_status" lay-filter="status">-->
<!--                        <option value="">请选择状态</option>-->
<!--                        <option value="-1">未知状态</option>-->
<!--                        <option value="0">待激活</option>-->
<!--                        <option value="1">已激活</option>-->
<!--                        <option value="2">已停机</option>-->
<!--                        <option value="3">已拆机</option>-->
<!--                    </select>-->
<!--                </div>-->
                <a class="layui-btn search_btn" data-type="reload">搜索</a>
            </div>

           <!-- <div class="layui-inline">
                <a class="layui-btn layui-btn-sm addNews_btn" onclick="update()">更新SIM信息</a>
            </div>-->
        </form>
    </blockquote>
    <table id="userList" lay-filter="userList">
        <script type="text/html" id="checkStatus">
           <!-- <input type="checkbox" name="{{d.company_id}}" value="{{d.status}}" lay-skin="switch" lay-text="启用|冻结" lay-filter="modifyStatus" {{ d.status== 1 ? 'checked' : '' }}>-->
        </script>

        <!--操作-->
        <script type="text/html" id="userListBar">

            <a class="layui-btn layui-btn-sm layui-btn-warm" onclick="sets('{{d.equipments_sn}}')">设置</a>
        </script>

    </table>
    <input type="hidden" id="company_id" name="company_id" value="{$company_id}"/>
</form>
{/block}

{block name="script"}
<script>
    layui.use(['laydate', 'form', 'layer', 'table', 'laytpl'], function () {
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery,
            laytpl = layui.laytpl,
            table = layui.table,
            laydate = layui.laydate;

        //日期范围
        laydate.render({
            elem: '#create_at'
            , range: true
        });
        var company_id=$('#company_id').val();

        //产品列表
        var tableIns = table.render({
            elem: '#userList',
            url:'/Api/Equipments/getLists',
            where:{"company_id":company_id},
            method: 'POST',
            contentType: 'application/json; charset=UTF-8',
            headers: {
                "token": 'bbbbb'
            },
            where:{app_sn:$("#app_sn").val()},
            cellMinWidth: 95,
            page: true,
            height: "full-125",
            limits: [10, 15, 20, 25],
            limit: 20,
            id: "userListTable",
            request: {
                limitName: 'pageSize', //每页数据量的参数名，默认：limit
            },
            cols: [[
                {type: "checkbox", fixed: "left", minWidth: 50},
                {field: 'equipments_id', title: 'ID', minWidth: 50, align: "center"},
                {field: 'equipments_name', title: '产品名称', minWidth: 200, align: "center"},
                {field: 'equipments_sn', title: '产品编号', minWidth: 200, align: 'center'},
                {field: 'equipments_type', title: '类型', minWidth: 200, align: 'center',templet: function (d) {
                    if(d.equipments_type==1){return "<p>租赁</p>"}else{return "<p>购买</p>"}
                    }},
                {field: 'equipments_money', title: '产品金额/元', minWidth: 200, align: 'center'},
                {title: '操作', minWidth: 175, templet: '#userListBar', fixed: "right", align: "center"}

            ]]
        });

        //搜索【此功能需要后台配合，所以暂时没有动态效果演示】
        $(".search_btn").on("click", function () {

            if ($(".searchVal").val() != '') {
                //执行重载
                table.reload('userListTable', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where: {
                        //传参数
                        equipments_sn: $(".equipments_sn").val(),
                        company_id:$("#company_id").val(),
                        app_sn:$("#app_sn").val(),

                    },

                });
                table.render();
                // layer.msg('查询成功');
            } else {
                layer.msg("请输入搜索的内容");
            }
        });



    });

    //设置服务费
    function sets(equipments_sn){
        var company_id=$("#company_id").val();
        var app_sn=$("#app_sn").val();
        window.location.href='{:url("equipments/sets")}?company_id='+company_id+'&equipments_sn='+equipments_sn+"&app_sn="+app_sn;
    }



</script>
{/block}
